package tests;
import javax.ejb.*;import beans.*;
import java.util.*;
import java.sql.*;
import entities.*;
import db.*;
public class BookManagerTest {

	
	public static void addMRTest(){
		System.out.println("Adding books");
		int dvdId=DBBookManager.addMasterRecord("Harry Potter and the philosophers stone", Item.DVD);
		int bookId=DBBookManager.addMasterRecord("Harry Potter and the philosophers stone", Item.CD);
		int dvdId2=DBBookManager.addMasterRecord("Harry Potter and the philosophers stone", Item.DVD);
		
		System.out.println("DVD id=" + dvdId);
		System.out.println("Item ID=" + bookId);
		System.out.println("DvdId2=" + dvdId2);
	}
	public static void deleteMRTest(){
		System.out.println("Deleting books");
		boolean dvdId=DBBookManager.deleteMasterRecord("Harry Potter and the philosophers stone", Item.DVD);
		boolean bookId=DBBookManager.deleteMasterRecord("Harry Potter and the philosophers stone", Item.CD);
		boolean dvdId2=DBBookManager.deleteMasterRecord("Harry Potter and the philosophers stone", Item.DVD);
		System.out.println("DVD id=" + dvdId);
		System.out.println("Item ID=" + bookId);
		System.out.println("DvdId2=" + dvdId2);
	}
	
	public static void addCopyTest(){
		Item item=new Item();
		item.setUserId(1);
		item.setMasterId(1);
		item.setLocationId(1);
		item.setCopyStatus(Item.inLib);
		
		boolean b=DBBookManager.addCopy(item);
		System.out.println("Copy added: " + b);
	}
	@EJB
	static BookManagerBean bean=new BookManagerBean();
	public static void addCopyTestBean(){
		Item item=new Item();
		item.setUserId(1);
		item.setTitle("math");
		item.setLocation("Toronto");
		item.setType(Item.BOOK);
		item.setVisible(Item.PRIVATE);
		boolean b=bean.addCopy(item);
		System.out.println("Bean worked for addcopy : " + b);
		
	}
	
	public static void findOwnerTest(){
		ArrayList<Item> items=DBBookManager.findOwnerItems(1, null, null, 5);
		System.out.println(items.size());
	}
	public static void main(String arg[]){
		//addMRTest();
		//
		//deleteMRTest();
		findOwnerTest();
	}
}
